package com.aaa.service.Impl;

import com.aaa.mapper.DeptMapper;
import com.aaa.pojos.Dept;
import org.springframework.stereotype.Service;
import com.aaa.service.DeptService;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Resource
    private DeptMapper deptMapper;

    @Override
    public List<Dept> queryAll() {
        List<Dept> depts = deptMapper.queryAll();
        return depts;
    }

    @Override
    public void deleteById(Integer id) {
     deptMapper.deleteById(id);
    }

    @Override
    public void addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.addDept(dept);
    }

    @Override
    public Dept getById(Integer id) {
        Dept dept = deptMapper.getById(id);
        return dept;
    }

    @Override
    public void updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }

}
